package org.example.smartEducationBackend.controller;

import org.example.smartEducationBackend.entity.DTO.CommentDTO;
import org.example.smartEducationBackend.entity.POJO.Comment;
import org.example.smartEducationBackend.entity.POJO.RestResult;
import org.example.smartEducationBackend.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;
    @PostMapping("/add")
    public RestResult<String> addVideoRating(@RequestBody Comment comment) {
        // 使用 MyBatis-Plus 的通用方法保存数据
        boolean success = commentService.save(comment);
        return RestResult.ok("success");

}

    @GetMapping("/list")
    public RestResult<List<CommentDTO>> getList(Integer video_id) {
        // 使用 MyBatis-Plus 的通用方法保存数据
         List<CommentDTO> commentDTOList = commentService.getByVideoId(video_id);
        return RestResult.ok(commentDTOList);

    }
}


